using System;
using System.Collections.Generic;
using System.Text;
using DDW.Collections;

namespace DDW
{
	public class CompilationUnitNode : BaseNode
	{
		private NodeCollection<UsingDirectiveNode> usingDirectives;
		private NodeCollection<AttributeNode> globalAttributes;
		private NodeCollection<NamespaceNode> namespaces;
		private NamespaceNode defaultNamespace;
		private IdentifierExpression defaultNamespaceName = new IdentifierExpression(new string[] { "defaultNamespace" });

		public CompilationUnitNode()
		{
			usingDirectives = new NodeCollection<UsingDirectiveNode>();
			globalAttributes = new NodeCollection<AttributeNode>();
			namespaces = new NodeCollection<NamespaceNode>();

			defaultNamespace = new NamespaceNode();
			defaultNamespace.Name = defaultNamespaceName;
			namespaces.Add(defaultNamespace);
		}

		public NodeCollection<NamespaceNode> Namespaces
		{
			get { return namespaces; }
			set { namespaces = value; }
		}

		public NodeCollection<UsingDirectiveNode> UsingDirectives
		{
			get { return usingDirectives; }
			set { usingDirectives = value; }
		}

		public NamespaceNode DefaultNamespace
		{
			get { return defaultNamespace; }
		}


        public override void ToSource(StringBuilder sb)
		{
			if (attributes != null)
			{
				attributes.ToSource(sb);
			}

			foreach (UsingDirectiveNode node in usingDirectives)
			{
				node.ToSource(sb);
			}

			foreach (NamespaceNode node in namespaces)
			{
				node.ToSource(sb);
			} 
        }
	
	}
}
